﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>后台管理系统</title>
    <meta name="author" content="DeathGhost"/>
    <link rel="stylesheet" type="text/css" href="Css/style.css">
    <!--[if lt IE 9]>
    <script src="Scripts/html5.js"></script>
    <![endif]-->
    <script src="Scripts/jquery.js"></script>
    <script src="Scripts/jquery.mcustomscrollbar.concat.min.js"></script>
    <script>
        (function ($) {
            $(window).load(function () {
                $("a[rel='load-content']").click(function (e) {
                    e.preventDefault();
                    var url = $(this).attr("href");
                    $.get(url, function (data) {
                        $(".content .mCSB_container").append(data); //load new content inside .mCSB_container
                        //scroll-to appended content
                        $(".content").mCustomScrollbar("scrollTo", "h2:last");
                    });
                });

                $(".content").delegate("a[href='top']", "click", function (e) {
                    e.preventDefault();
                    $(".content").mCustomScrollbar("scrollTo", $(this).attr("href"));
                });

            });
        })(jQuery);

        function  delect(state,id) {
            $(".pop_cont_text").html("确定要下架商品吗？")
            $(".pop_bg").fadeIn();
            //弹出：确认按钮
            $(".trueBtn").click(function(){
                $.get("GoodsServlet?opr=delect&state="+state+"&id="+id,function (data) {
                    if (data=="true"){
                        location.href="GoodsServlet?opr=pagelist";
                        // $(ele).parent().parent().remove();
                        //刷新页面
                    }else if (data=="false"){
                        location.reload();
                    }
                })
                $(".pop_bg").fadeOut();
                location.href="GoodsServlet?opr=pagelist";
            });

            //弹出：取消或关闭按钮
            $(".falseBtn").click(function(){
                $(".pop_bg").fadeOut();
                location.reload();
            });
        }
    </script>
</head>
<body>
<!--header-->
<header>
    <h1><img src="Picture/admin_logo.png"/></h1>
    <ul class="rt_nav">
        <li><a href="#" class="website_icon">站点首页</a></li>
        <li><a href="#" class="admin_icon">DeathGhost</a></li>
        <li><a href="#" class="clear_icon">清除缓存</a></li>
        <li><a href="#" class="set_icon">账号设置</a></li>
        <li><a href="login.jsp" class="quit_icon">安全退出</a></li>
    </ul>
</header>
<!--aside nav-->
<!--aside nav-->
<aside class="lt_aside_nav content mCustomScrollbar">
    <h2><a href="index.jsp">起始页</a></h2>
    <ul>
        <li>
            <dl>
                <dt>商品信息</dt>
                <!--当前链接则添加class:active-->
                <dd><a href="product_list.jsp" class="active">商品列表</a></dd>
                <dd><a href="recycle_bin.jsp">商品回收站</a></dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>订单信息</dt>
                <dd><a href="order_list.jsp">订单列表</a></dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>配送</dt>
                <dd><a href="express_list.jsp">配送方式</a></dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>在线统计</dt>
                <dd><a href="discharge_statistic.jsp" >流量统计</a></dd>
                <dd><a href="sales_volume.jsp">销售额统计</a></dd>
            </dl>
        </li>
        <li>
            <p class="btm_infor">© DeathGhost.cn 版权所有</p>
        </li>
    </ul>
</aside>
<section class="pop_bg">
    <div class="pop_cont">
        <!--title-->
        <h3>操作响应</h3>
        <!--content-->
        <!--以pop_cont_text分界-->
        <div class="pop_cont_text">
            商品已经下架。
        </div>
        <!--bottom:operate->button-->
        <div class="btm_btn">
            <input type="button" value="确认" class="input_btn trueBtn"/>
            <input type="button" value="关闭" class="input_btn falseBtn"/>
        </div>
    </div>
</section>
<section class="rt_wrap content mCustomScrollbar">
    <div class="rt_content">
        <div class="page_title">
            <h2 class="fl">商品列表</h2>
            <a href="product_detail.jsp" class="fr top_rt_btn add_icon">添加商品</a>
        </div>

        <form method="post" action="GoodsServlet?opr=pagelist">

            <section class="mtb">
                <select class="select" name="sort">
                    <c:if test="${sort=='time'}">
                        <option value="time" selected>按时间</option>
                    </c:if>
                    <c:if test="${sort=='price'}">
                        <option value="price" selected>按价格(从小到大)</option>
                    </c:if>
                    <!--第三-->
                    <c:if test="${sort!='time'}">
                        <option value="time">按时间</option>
                    </c:if>
                    <c:if test="${sort!='price'}">
                        <option value="price">按价格(从小到大)</option>
                    </c:if>
                </select>

                <input type="text" class="textbox textbox_225" value="${textbox}" placeholder="输入产品关键词或产品货号..."
                       name="textbox" id="textbox"/>

                <input type="submit" value="查询" id="cx" class="group_btn"/>
            </section>
        </form>
        <table class="table">
            <tr>
                <th>缩略图</th>
                <th>产品名称</th>
                <th>货号</th>
                <th>单价</th>
                <th>单位</th>
                <th>上架时间</th>
                <th>库存</th>
                <th>操作</th>
            </tr>
            <c:if test="${page==null}">
                <c:redirect url="GoodsServlet?opr=pagelist&pageNo=1&sort=${sort}"/>
            </c:if>
            <c:forEach items="${page.list}" var="goods">
                <tr>
                    <td class="center"><img src="${goods.filePath}" width="50" height="50"/></td>
                    <td>${goods.goodsName}</td>
                    <td class="center">${goods.goodsID}</td>
                    <td class="center"><strong class="rmb_icon">${goods.price}</strong></td>
                    <td class="center">${goods.units}</td>
                    <td class="center">${goods.goodsTime}</td>
                    <td class="center">${goods.inventory}</td>
                    <td class="center">
                        <a href="GoodsServlet?opr=detail&id=${goods.goodsID}&sort=${sort}" title="预览" class="link_icon">修改</a>
                        <a href="#" id="delect" onclick="delect(${goods.state},${goods.goodsID},this)" title="下架" class="link_icon">下架</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <aside class="paging">
            <a href="GoodsServlet?opr=pagelist&pageNo=1&sort=${sort}">首页</a>
            <!--当页数小于2的时候不显示上一页按钮-->
            <c:if test="${page.pageNo>1}">
                <a href="GoodsServlet?opr=pagelist&pageNo=${page.pageNo-1}&sort=${sort}">上一页</a>
            </c:if>
            <a href="#">${page.pageNo}</a>
            <!--当页数大于等于最后一页的时候不显示下一页按钮-->
            <c:if test="${page.pageNo<page.totalPage}">
                <a href="GoodsServlet?opr=pagelist&pageNo=${page.pageNo+1}&sort=${sort}">下一页</a>
            </c:if>
            <a href="GoodsServlet?opr=pagelist&pageNo=${page.totalPage}&sort=${sort}">最后一页</a>
        </aside>
    </div>
</section>
</body>
</html>
<script src="jquery.js"></script>
